package dataStructure.xmg1.a13.model;

/**
 * @author: vince_zww
 * @date: 2021/6/13 15:48
 * @desceription:
 */
public class Person {
    private int age;
    private float height;
    private String name;

    public Person(int age, float height, String name) {
        this.age = age;
        this.height = height;
        this.name = name;
    }


    @Override
    /**
     * 用来比较2个对象是否相等
     */
    public boolean equals(Object obj) {
        // 内存地址
        if (this == obj) return true;
        if (obj == null || obj.getClass()!=getClass()) return false;
        // 比较成员变量
        Person person = (Person)obj;
        return person.age==age
                && person.height ==height
                && (person.name==null?name==null:person.name.equals(name));
    }

    @Override
    public int hashCode() {
        return super.hashCode();
    }
}
